package com.turato.builder;

import lombok.Data;

/**
 * @author tuhao
 * @date 2021/2/7 7:43 下午
 * @desc
 */
@Data
public class DataHolder {
    private String nickname;
    private String headImgUrl;
    private String userId;
    private Object headPosition;
    private Object namePosition;
    private String backGroundPicUrl;

    public DataHolder() {}
    public DataHolder(Builder builder) {
        this.nickname = builder.nickname;
        this.headImgUrl = builder.headImgUrl;
        this.userId = builder.userId;
        this.headPosition = builder.headPosition;
        this.namePosition = builder.namePosition;
        this.backGroundPicUrl = builder.backGroundPicUrl;
    }

    /**
     * 通过这个静态内部类来构造 DataHolder 对象
     */

    public static class Builder{
        private String nickname;
        private String headImgUrl;
        private String userId;
        private Object headPosition;
        private Object namePosition;
        private String backGroundPicUrl;
        public Builder() {
        }
        // 通过方法来给DataHolder类的属性赋值,
        // 注意，方法要返回 Builder 本身,方便链式调用
        public Builder nickname(String nickname) {
            this.nickname = nickname;
            return this;
        }

        public Builder headImgUrl(String headImgUrl) {
            this.headImgUrl = headImgUrl;
            return this;
        }

        public Builder userId(String userId) {
            this.userId = userId;
            return this;
        }

        public Builder headPosition(Object headPosition) {
            this.headPosition = headPosition;
            return this;
        }

        public Builder namePosition(Object namePosition) {
            this.namePosition = namePosition;
            return this;
        }

        public Builder backGroundPicUrl(String backGroundPicUrl) {
            this.backGroundPicUrl = backGroundPicUrl;
            return this;
        }
        public DataHolder build(){
            return new DataHolder(this);
        }
    }
}